<?php

namespace app\admin\model\service\skill;

use think\Model;
use traits\model\SoftDelete;

class Skill extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'service_skill';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'sex_text',
        'edu_text',
        'exper_text',
        'is_rest_text',
        'is_train_text',
        'state_text'
    ];
    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getSexList()
    {
        return ['1' => __('Sex 1'), '0' => __('Sex 0')];
    }

    public function getEduList()
    {
        return ['0' => __('Edu 0'), '1' => __('Edu 1'), '2' => __('Edu 2'), '3' => __('Edu 3'), '4' => __('Edu 4'), '5' => __('Edu 5'), '6' => __('Edu 6')];
    }

    public function getExperList()
    {
        return ['0' => __('Exper 0'), '1' => __('Exper 1'), '2' => __('Exper 2'), '3' => __('Exper 3')];
    }

    public function getIsRestList()
    {
        return ['0' => __('Is_rest 0'), '1' => __('Is_rest 1')];
    }

    public function getIsTrainList()
    {
        return ['0' => __('Is_train 0'), '1' => __('Is_train 1')];
    }

    public function getStateList()
    {
        return ['0' => __('State 0'), '1' => __('State 1')];
    }


    public function getSexTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
        $list = $this->getSexList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getEduTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['edu']) ? $data['edu'] : '');
        $list = $this->getEduList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getExperTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['exper']) ? $data['exper'] : '');
        $list = $this->getExperList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsRestTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_rest']) ? $data['is_rest'] : '');
        $list = $this->getIsRestList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsTrainTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_train']) ? $data['is_train'] : '');
        $list = $this->getIsTrainList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
